package com.yushutao.menu;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.yushutao.menu.beans.OrderBean;
import com.yushutao.menu.dao.IOrder;
import com.yushutao.menu.dao.impl.OrderDAO;

@Controller
@RequestMapping(value = "chef")
public class ChefController {
	
	private static final Logger logger = LoggerFactory.getLogger(ChefController.class);
//	private static final IDish dishDAO = new DishDAO();
//	private static final IUser userDAO = new UserDAO();
	private static final IOrder orderDAO = new OrderDAO();
	
	/**
	 * 显示主页有什么菜需要制作
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String showIndex(Model model) {
		logger.debug("req showIndex");
		List<OrderBean> all = orderDAO.getAllNeedCookie();
		model.addAttribute("ordered", all);
		return "chef/index";
	}
	/**
	 * 处理菜单
	 */
	@RequestMapping(value = "/doFinishOrder/{oCode}", method = RequestMethod.GET)
	public String doFinishOrder(@PathVariable("oCode")int oCode,Model model) {
		logger.debug("req doFinishOrder");
		orderDAO.finishCook(oCode);
		return "redirect:/chef/";
	}
}
